import java.util.concurrent.*;

/**
 * @author honway.liu
 * @date 2019-05-29 11:18
 * @email gm100861@gmail.com
 * @blog http://linuxsogood.org
 */
public class A {

    private static int i = 0;
    private static CountDownLatch latch = new CountDownLatch(10);
    public static void main(String[] args) throws ExecutionException, InterruptedException, TimeoutException {

        new Thread(() -> {
            try {
                read();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "READ").start();
        new Thread(() -> {
            try {
                write();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "WRITE").start();
    }


    public static void read() throws InterruptedException {
        System.out.println("read start");
        TimeUnit.SECONDS.sleep(300);
        System.out.println("read ok.");
    }

    public static void write() throws InterruptedException {
        System.out.println("write start");
        TimeUnit.SECONDS.sleep(300);
        System.out.println("write ok");
    }

    public static int method1() {
        System.out.println("method begin execute");
        try {
            System.out.println("try it");
            System.out.println(1/0);
        } catch (Exception e) {
            System.out.println("exception.");
            return -1;
        } finally {
            System.out.println("finally");
            return 5;
        }
    }
}
